var t = getApp();

Page({
    data: {
        language: "",
        Height: 0,
        LastHeight: 0,
        show: !1,
        activeName: 0,
        titleArr: [ {
            id: 0,
            name: "全部"
        } ],
        shareData: {},
        Banner: [],
        dataList: [],
        serch_title: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    imgHeight: function(t) {
        var a = wx.getSystemInfoSync().windowWidth * t.detail.height / t.detail.width + "px";
        parseInt(a) > this.data.LastHeight && (this.setData({
            Height: a
        }), this.data.LastHeight = parseInt(a));
    },
    openIntroduction: function() {
        this.setData({
            show: !0
        });
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        }), this.getdata(!1), this.getShare();
    },
    closeM: function() {
        this.setData({
            show: !1
        });
    },
    handleClick: function(t) {
        this.setData({
            activeName: t.detail.index
        }), this.getdata(!0);
    },
    getdata: function(a) {
        var e = this, i = t.getNetAddresss("plugin.snatch-regiment.api.index.getSnatchData");
        t._getNetWork({
            url: i,
            data: {
                art: "index",
                title: this.data.serch_title || 0,
                cate_id: this.data.titleArr ? this.data.titleArr[this.data.activeName].id : 0
            },
            success: function(t) {
                var i = t.data;
                if (1 == i.result) {
                    if (!a) {
                        var n = e.data.titleArr;
                        e.setData({
                            Banner: i.data.index.slide,
                            titleArr: n.concat(i.data.index.category),
                            explain: i.data.index.explain
                        });
                    }
                    e.setData({
                        isLoadMore: !0,
                        page: 1,
                        total_page: i.data.index.goods.last_page,
                        dataList: i.data.index.goods.data
                    });
                } else wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getShare: function() {
        var a = this, e = t.getNetAddresss("plugin.snatch-regiment.api.index.getSnatchData");
        e += "&art=getShare", t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    shareData: e.data.getShare
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            }
        });
    },
    gotoGrabGroup: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a + "&name=69"
        });
    },
    searchbtn: function(t) {
        var a = t.detail.value;
        this.setData({
            serch_title: a
        });
    },
    searchConfirm: function() {
        this.getdata(!0);
    },
    gotoMyGroup: function() {
        wx.navigateTo({
            url: "/packageE/grab_group/grab_group_my/grab_group_my"
        });
    },
    goToUrl: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.url;
        try {
            wx.navigateTo({
                url: a
            });
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    _getMoreData: function() {
        var a = this, e = {}, i = "", n = "";
        a.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        i = "plugin.snatch-regiment.api.index.getSnatchData", e = {
            page: a.data.page,
            art: "index",
            title: a.data.serch_title || 0,
            cate_id: a.data.titleArr[a.data.activeName].id
        }, n = t.getNetAddresss(i), t._postNetWork({
            url: n,
            showToastIn: !1,
            data: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    isLoadMore: !0,
                    dataList: a.data.dataList.concat(e.data.index.goods.data)
                }) : a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        }));
    },
    onShareAppMessage: function() {
        return {
            title: this.data.shareData.share_title,
            imageUrl: this.data.shareData.share_img,
            path: "/packageE/grab_group/grab_group_home/grab_group_home"
        };
    }
});